﻿@page "/consent"
@page "/consent/index"

@inherits SsoCompontentBase
@layout SimpleLayout

@if (_viewModel != null)
{
    <MCard Width=510 Height=680 Class="mx-auto my-auto px-12">
        <MCardTitle>
            <p class="h5 mt-4">
                @T("Authorize")
                &ensp;<span>@_viewModel.ClientName</span>&ensp;
                @T("FollowingPermissions")
            </p>
        </MCardTitle>
        <MCardText Style="height: auto;">

            @if (_viewModel.ClientLogoUrl != null)
            {
                <div class="text-center mt-4"><img style="max-height:120px;max-width:120px;" src="@_viewModel.ClientLogoUrl"></div>
            }
            @if (_viewModel.IdentityScopes.Any())
            {
                <ul class="pl-0">
                    @for (var i = 0; i < _viewModel.IdentityScopes.Count(); i++)
                    {
                        var scope = _viewModel.IdentityScopes.ElementAt(i);
                        <_ScopeListItem @bind-ScopeViewModel="scope" />
                    }
                </ul>
            }
            @if (_viewModel.ApiScopes.Any())
            {
                <ul class="pl-0">
                    @for (var i = 0; i < _viewModel.ApiScopes.Count(); i++)
                    {
                        var scope = _viewModel.ApiScopes.ElementAt(i);
                        <_ScopeListItem @bind-ScopeViewModel="scope" />
                    }
                </ul>
            }
        </MCardText>

        @if (_viewModel.AllowRememberConsent)
        {
            <MCheckbox @bind-Value="_viewModel.RememberConsent" Label="@T("RememberMyDecision")" TValue="bool"/>
        }

        <MButton Class="mt-12 rounded-4 text-btn white--text" Block OnClick="()=>OnConsent(true)" Height=46 Width=340 Color="primary">@T("Agree")</MButton>
        @*<MButton Class="mt-6 rounded-4 text-btn primary--text" Block OnClick="()=>OnConsent(false)" Height=46 Width=340>@T("Reject")</MButton>*@

        <div class="full-width text-center mt-4">
            @if (_viewModel.ClientUrl != null)
            {
                <MButton class="ma-2" Href="@_viewModel.ClientUrl" Outlined Color="indigo">
                    <MIcon>mdi-keyboard-return</MIcon>
                    @_viewModel.ClientName
                </MButton>
            }
        </div>
    </MCard>
}
